package com.jmxcfc.blfsc.common.validation.rule;

import com.jmxcfc.blfsc.common.validation.IRuleValidator;

/**
 * 请求参数校验规则
 * 使用方式:
 * 1、当ruleType为CLASS时,则需要指定对应的Class处理
 * 2、当ruleType为REGEX时,则需要指定对应的regular expression
 * 该类只提供of创建,不允许修改属性
 */
public class RequestFieldRule<T> {

    private String field;
    private IRuleValidator<T> ruleValidator;
    private String errorDesc;

    public RequestFieldRule(String field, IRuleValidator<T> ruleValidator, String errorDesc) {
        this.field = field;
        this.ruleValidator = ruleValidator;
        this.errorDesc = errorDesc;
    }

    public static <T> RequestFieldRule<T> of(String field, IRuleValidator<T> ruleValidator, String errorDesc) {
        return new RequestFieldRule<>(field, ruleValidator, errorDesc);
    }

    public IRuleValidator<T> getRuleValidator() {
        return ruleValidator;
    }

    public void setRuleValidator(IRuleValidator<T> ruleValidator) {
        this.ruleValidator = ruleValidator;
    }

    public String getField() {
        return field;
    }

    public void setField(String field) {
        this.field = field;
    }

    public String getErrorDesc() {
        return errorDesc;
    }

    public void setErrorDesc(String errorDesc) {
        this.errorDesc = errorDesc;
    }


}
